<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>跑马灯效果</title>
  <script src="../../lib/vue.js"></script>
  <!-- <link rel="stylesheet" href="../lib/zyySelf.css"> -->
  <style>
    .BigGreen {
      background-color: #4CAF50;
      border: none;
      border-radius: 12px;
      color: white;
      padding: 15px 32px;
      text-align: center;
      text-decoration: none;
      display: inline-block;
      font-size: 16px;
      margin: 20px;
    }
  </style>
</head>

<body>
  <div id="app">
    <div style="text-align: center;">
      <input class="BigGreen" type="button" value="浪起来" @click="goLang()">
      <input class="BigGreen" type="button" value="低调" @click="stop()">
    </div>
    <div style="text-align: center;">
      <h1>{{msg}}</h1>
    </div>
  </div>
</body>
<script>
  var vm = new Vue({
    el: '#app',
    data: {
      msg: "猥琐发育，别浪～～",
      // flag: false,
      intervalID: null
    },
    methods: {
      goLang()
      {
        if (this.intervalID == null)
        {
          this.intervalID = setInterval(() =>
          {
            var start = this.msg.substring(0, 1);
            var end = this.msg.substring(1);
            this.msg = end + start;
          }, 400);
          // this.flag = true;
        }
      },
      stop()
      {
        clearInterval(this.intervalID);
        this.intervalID = null;
      }
    },
  })
</script>

</html>